package cn.demo.act.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.demo.common.annotation.Log;
import cn.demo.common.core.controller.BaseController;
import cn.demo.common.core.domain.R;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.demo.common.enums.BusinessType;
import cn.demo.act.domain.ActRegister;
import cn.demo.act.service.IActRegisterService;
import cn.demo.common.utils.poi.ExcelUtil;
import cn.demo.common.core.page.PageR;
import cn.demo.common.core.page.PageQuery;
import com.mybatisflex.core.paginate.Page;


/**
 * 活动报名管理Controller
 *
 * @author xtjun
 * @date 2024-06-04
 */
@Tag(name = "活动报名管理")
@RestController
@RequestMapping("/act/actRegister")
public class ActRegisterController extends BaseController {
    @Resource
    private IActRegisterService actRegisterService;

    @Operation(summary = "查询活动报名管理列表")
    @PreAuthorize("@ss.hasPermi('act:actRegister:list')")
    @GetMapping("/list")
    public PageR<ActRegister> list(ActRegister actRegister, PageQuery pageQuery) {
        Page<ActRegister> page = actRegisterService.selectActRegisterPage(actRegister, pageQuery);
        return PageR.ok(page);
    }

    @Operation(summary = "导出活动报名管理列表")
    @PreAuthorize("@ss.hasPermi('act:actRegister:export')")
    @Log(title = "活动报名管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActRegister actRegister) {
        List<ActRegister> list = actRegisterService.selectActRegisterList(actRegister);
        ExcelUtil<ActRegister> util = new ExcelUtil<ActRegister>(ActRegister.class);
        util.exportExcel(response, list, "活动报名管理数据");
    }

    @Operation(summary = "获取活动报名管理详细信息")
    @PreAuthorize("@ss.hasPermi('act:actRegister:query')")
    @GetMapping(value = "/{id}")
    public R<ActRegister> getInfo(@PathVariable("id") String id) {
        return R.ok(actRegisterService.selectActRegisterById(id));
    }

    @Operation(summary = "新增活动报名管理")
    @PreAuthorize("@ss.hasPermi('act:actRegister:add')")
    @Log(title = "活动报名管理", businessType = BusinessType.INSERT)
    @PostMapping
    public R add(@RequestBody ActRegister actRegister) {
        return toAjax(actRegisterService.insertActRegister(actRegister));
    }

    @Operation(summary = "修改活动报名管理")
    @PreAuthorize("@ss.hasPermi('act:actRegister:edit')")
    @Log(title = "活动报名管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public R edit(@RequestBody ActRegister actRegister) {
        return toAjax(actRegisterService.updateActRegister(actRegister));
    }

    @Operation(summary = "删除活动报名管理")
    @PreAuthorize("@ss.hasPermi('act:actRegister:remove')")
    @Log(title = "活动报名管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public R remove(@PathVariable List<String> ids) {
        return toAjax(actRegisterService.deleteActRegisterByIds(ids));
    }
}
